package com.findsing.jetty.websocket.server.config;

import org.eclipse.jetty.server.session.HashSessionIdManager;
import org.eclipse.jetty.server.session.HashSessionManager;
import org.eclipse.jetty.server.session.SessionHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ApplicationConfig {
	
	private static SessionHandler sessionHandler = null;
	@Bean
	public SessionHandler getSessionHandler()
	{
		if(null == sessionHandler)
		{
			HashSessionIdManager sessionIdManager = new HashSessionIdManager();
			HashSessionManager sessionManager = new HashSessionManager();
			sessionManager.setSessionIdManager(sessionIdManager);
			sessionHandler = new SessionHandler(sessionManager);
		}
		
		return sessionHandler;
	}
}
